package mammuthus.slave

import akka.actor._
import mammuthus.protocal._
import net.csdn.common.logging.Loggers
import mammuthus.protocal.RegisterAgent
import mammuthus.protocal.RegisterAgentSuccess


class MasterActorRef(akkaSlave: Slave) extends Actor {
  val logger = Loggers.getLogger(getClass)

  def actorRefs = {
    akkaSlave.masterUrls.map(f => context.actorSelection(f))
  }

  override def receive: Receive = {
    case RegisterAgent(poolId, actorUrl, slaveInfo: AgentInfo) =>
      actorRefs.foreach {
        ref =>
          ref ! RegisterAgent(poolId, actorUrl, slaveInfo)
      }
    case RegisterAgentSuccess =>
      logger.info("slave ---> master clear")
    case _ => sender ! "没有可执行的命令"
  }
}






